/**
 * Copyright (c) 2020-2021 浦东大爷 All rights reserved.
 * 机会永远都是留给有准备的人
 */
package com.learning.moudle3;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author: gitwo
 * @date: 2020-11-19
 * @description:
 */
public class CollectionTest {

    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add(1);
        c1.add(2);
        c1.add("abc");

        System.out.println("c1" + c1);

        System.out.println("---------------------------");

        Iterator iterator1 = c1.iterator();

        while (iterator1.hasNext()) {
            Object next = iterator1.next();
            System.out.println(next);
            if("abc".equals(next)) iterator1.remove();
            if(2 == (next instanceof Integer ? ((Integer) next).intValue() : 0)) iterator1.remove();

        }
        System.out.println("c1=" + c1);
        System.out.println("---------------------------");

        System.out.println();
    }
}
